package by.siarhei.java.tij.reusing.exercises.ex18;

/**
 * @author Siarhei Shchahratsou <s.siarhei@gmail.com>
 * @since 18.03.14
 */
public class Excercise18 {
    public static void main(String[] args) {
        Holder holder1 = new Holder();
        Holder holder2 = new Holder();

        //true: the same reference
        System.out.println("holder1.STATIC_FINAL.equals(holder2.STATIC_FINAL): "+ holder1.STATIC_FINAL.equals(holder2.STATIC_FINAL));
        //false: the different reference
        System.out.println("holder1.object.equals(holder2.object): "+ holder1.object.equals(holder2.object));

        //java: cannot assign a value to final variable STATIC_FINAL
        //holder1.STATIC_FINAL = new Object();

        //java: cannot assign a value to final variable STATIC_FINAL
        //Holder.STATIC_FINAL = new Object();

        //java: cannot assign a value to final variable object
        //holder2.object = new Object();
    }
}

class Holder {
    public static final Object STATIC_FINAL = new Object();
    final Object object = new Object();
}
